package com.jlp.source.controller;

import com.jlp.source.domain.User;
import com.jlp.source.manager.UserManager;
import com.jlp.source.service.UserService;
import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Random;

/**
 * @author lingpeng.jiang
 * @create 2022-01-09 14:42
 * @Description //TODO
 **/
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @Resource
    private UserManager userManager;


    @GetMapping("/get")
    public User selectUserById(){
        User user;
        if (new Random().nextInt(100) % 2 == 0){
            user  = userService.selectUserById(2L);
        } else {
            user = userService.selectUserByDB1ById(2L);
        }
        return user;
    }


    @GetMapping("/update")
    public String updateUser(){
        return userManager.insertUser();
    }
}
